<?php

/**
 * This is the model class for table "uc_user".
 *
 * The followings are the available columns in table 'uc_user':
 * @property string $user_id
 * @property string $name
 * @property string $en_name
 * @property integer $age
 * @property integer $gender
 * @property double $target_weight
 * @property string $create_time
 * @property string $update_time
 * @property string $created_by
 * @property string $updated_by
 * @property integer $is_delete
 * @property string $target_date
 * @property double $weight_diff
 * @property double $target_weight_diff
 * @property double $distance_to_target
 * @property string $weight_list
 * @property string $email
 */
class UcUser extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return UcUser the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'uc_user';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('name', 'required'),
			array('age, gender, is_delete', 'numerical', 'integerOnly'=>true),
			array('target_weight, weight_diff, target_weight_diff, distance_to_target', 'numerical'),
			array('name, en_name, created_by, updated_by, email', 'length', 'max'=>255),
			array('create_time, update_time, target_date, weight_list', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('user_id, name, en_name, age, gender, target_weight, create_time, update_time, created_by, updated_by, is_delete, target_date, weight_diff, target_weight_diff, distance_to_target, weight_list, email', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'user_id' => 'User',
			'name' => 'Name',
			'en_name' => 'En Name',
			'age' => 'Age',
			'gender' => 'Gender',
			'target_weight' => 'Target Weight',
			'create_time' => 'Create Time',
			'update_time' => 'Update Time',
			'created_by' => 'Created By',
			'updated_by' => 'Updated By',
			'is_delete' => 'Is Delete',
			'target_date' => 'Target Date',
			'weight_diff' => 'Weight Diff',
			'target_weight_diff' => 'Target Weight Diff',
			'distance_to_target' => 'Distance To Target',
			'weight_list' => 'Weight List',
			'email' => 'Email',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('user_id',$this->user_id,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('en_name',$this->en_name,true);
		$criteria->compare('age',$this->age);
		$criteria->compare('gender',$this->gender);
		$criteria->compare('target_weight',$this->target_weight);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time,true);
		$criteria->compare('created_by',$this->created_by,true);
		$criteria->compare('updated_by',$this->updated_by,true);
		$criteria->compare('is_delete',$this->is_delete);
		$criteria->compare('target_date',$this->target_date,true);
		$criteria->compare('weight_diff',$this->weight_diff);
		$criteria->compare('target_weight_diff',$this->target_weight_diff);
		$criteria->compare('distance_to_target',$this->distance_to_target);
		$criteria->compare('weight_list',$this->weight_list,true);
		$criteria->compare('email',$this->email,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}